package com.supor.aiot.food.adapter;

import android.text.TextUtils;
import android.view.View;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.supor.aiot.food.R;
import com.supor.aiot.food.bean.RecipeHotBean;

import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.util.List;

public class SharedRecipe1Adapter extends BaseQuickAdapter<RecipeHotBean, BaseViewHolder> {
    private boolean descVisiable;
    public SharedRecipe1Adapter(int layoutResId, @Nullable List<RecipeHotBean> data) {
        super(layoutResId, data);
    }

    public void setDescVisiable(boolean visiable){
        this.descVisiable = visiable;
    }

    @Override
    protected void convert(@NotNull BaseViewHolder baseViewHolder, RecipeHotBean hotBean) {
        if (!TextUtils.isEmpty(hotBean.getImageVertical()))Glide.with(this.getContext()).load(hotBean.getImageVertical()).into((ImageView) baseViewHolder.getView(R.id.iv_recipe_hot));
        if (!TextUtils.isEmpty(hotBean.getCrmModelName()))baseViewHolder.setText(R.id.tv_hot_device,hotBean.getCrmModelName());
        if (!TextUtils.isEmpty(hotBean.getRecipeName()))baseViewHolder.setText(R.id.tv_shared_img_tag,hotBean.getRecipeName());
        if (!TextUtils.isEmpty(hotBean.getRecipeType()) && hotBean.getRecipeType().equals("VIDEO")) {
            baseViewHolder.setVisible(R.id.iv_play_vedio,true);
        } else {
            baseViewHolder.setVisible(R.id.iv_play_vedio,false);
        }
        if (descVisiable&&!TextUtils.isEmpty(hotBean.getRecipeContent())){
            baseViewHolder.setVisible(R.id.tv_recipe_desc,descVisiable);
            baseViewHolder.setText(R.id.tv_recipe_desc,hotBean.getRecipeContent());
        }else {
            baseViewHolder.setGone(R.id.tv_recipe_desc,true);
        }
    }
}
